﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using BLToolkit.Data;
using BLToolkit.DataAccess;
using BLToolkit.Mapping;
using Enities;
using BLL.Repository;


namespace BLL
{
    public class LuuTruTaiLieu : ILuuTruTaiLieu
    {
        public DataTable Laydanhsach()
        {
            using (DbManager db = new DbManager())
            {
                DataTable table = db.SetSpCommand("[TaiLieu_DanhSach]").ExecuteDataTable();
                return table;

            }
        }
        //public DataTable SelectByID(string MaTaiLieu)
        //{
        //    using (DbManager db = new DbManager())
        //    {
        //        DataTable table = db.SetSpCommand("[TaiLieu_KTMA]").ExecuteDataTable();
        //        return table;

        //    }
        //}
        public DataTable LaymaTLoai()
        {
            using (DbManager db = new DbManager())
            {
                DataTable table = db.SetSpCommand("ViTriLuuTru_DanhSach").ExecuteDataTable();
                return table;
            }
        }

        public void ThemTL(TaiLieu tl)
        {
            using (DbManager db = new DbManager())
            {
                db.SetSpCommand("[TaiLieu_Them]", tl.MaTaiLieu, tl.TenTaiLieu, tl.TheLoai, tl.ChuyenNganh, tl.TacGia,
                    tl.NhaXuatBan, tl.LanTaiBan, tl.MoTa, tl.GiaBia, tl.SoTrang, tl.MaLuuTru, tl.NgayNhap, tl.TrangThai, tl.TinhTrang).ExecuteNonQuery();
            }
        }

        public void SuaTL(TaiLieu tl)
        {
            using (DbManager db = new DbManager())
            {
                db.SetSpCommand("[TaiLieu_Sua]", tl.MaTaiLieu, tl.TenTaiLieu, tl.TheLoai, tl.ChuyenNganh, tl.TacGia,
                    tl.NhaXuatBan, tl.LanTaiBan, tl.MoTa, tl.GiaBia, tl.SoTrang, tl.MaLuuTru, tl.NgayNhap, tl.TrangThai, tl.TinhTrang).ExecuteNonQuery();

            }
        }

        public void XoaTL(string MaTaiLieu)
        {
            using (DbManager db = new DbManager())
            {
                db.SetSpCommand("[TaiLieu_Xoa]", MaTaiLieu).ExecuteNonQuery();
            }
        }

        public DataTable timkiemdongian(string MaTaiLieu, string TenTaiLieu)
        {
            using (DbManager db = new DbManager())
            {
                DataTable table = db.SetSpCommand("[TaiLieu_TKDGian]", MaTaiLieu, TenTaiLieu).ExecuteDataTable();
                return table;
            }
        }

        public DataTable timkiemnangcao(string MaTaiLieu, string TenTaiLieu, string NhaXuatBan, string TheLoai, string TacGia)
        {
            using (DbManager db = new DbManager())
            {
                DataTable table = db.SetSpCommand("[TaiLieu_TKNangCao]", MaTaiLieu, TenTaiLieu, NhaXuatBan, TheLoai, TacGia).ExecuteDataTable();
                return table;
            }
        }

       
    }
}